using System;
/// <summary>
/// 资源任务
/// </summary>
public abstract partial class AbsHFTask : IHFRecycle
{
    /// <summary>
    /// 是否回收
    /// </summary>
    public bool isRecycle { get; private set; }

    /// <summary>
    /// Recycle之后
    /// </summary>
    public event Action<IHFRecycle> OnAfterRecycleHandler;

    /// <summary>
    /// 回收任务
    /// </summary>
    public void Recycle()
    {
        isRecycle = true;
        Cancel();        
        OnRecycle();
        OnAfterRecycleHandler?.Invoke(this);
        OnAfterRecycleHandler = null;
    }

    /// <summary>
    /// 回收任务
    /// </summary>
    protected virtual void OnRecycle() { }
}